package com.example.demo.pattern.iteratorpattern;

import java.util.Iterator;

public abstract class MenuComponent {
    protected String name;

    public String getName() {
        return name;
    }

    protected void addMenu(MenuComponent menuComponent) {
        throw new UnsupportedOperationException("暂不支持");
    }

    protected abstract void print();

    //不同数据类型的子类通过重写返回同样的迭代器
    protected abstract Iterator<MenuComponent> iterator();
}